import React from 'react';
import { IDictionaryTypeState } from './useDictionaryTypeReducer';

export interface IDictionaryContext extends IDictionaryTypeState {
  prefixCls: string;
  treeData: Record<string, any>[];
  commonDispatch: React.Dispatch<any>;
  reloadTableDataSource: (id: string) => void;
  searchTableValue: string;
  curRes: Record<string, any>
}

const INIT_DICTIONARY_VALUE: IDictionaryContext = {
  prefixCls: '',
  searchValue: '',
  treeData: [],
  selectKeys: [],
  expandedKeys: [],
  autoExpandParent: false,
  commonDispatch: () => { },
  reloadTableDataSource: (id) => { },
  searchTableValue: '',
  curRes: {},
};

export const DictionaryContext = React.createContext<IDictionaryContext>(
  INIT_DICTIONARY_VALUE,
);
